package com.asset.dispoal.abolishPool;

import com.asset.dispoal.abolishPool.api.AbolishPoolService;
import com.asset.dispoal.abolishPool.dto.AbolishPoolResponse;
import com.asset.dispoal.abolishPool.dto.QueryAbolishPoolRequest;
import com.asset.dispoal.abolishPool.dto.SaveAbolishPoolRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.core.util.StringUtil;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @description: 废案池
 * @author: yf
 * @date: 2022-09-22 13:42:26
 */
@RestController
@RequestMapping("gb/abolishPool")
@Api(value = "废案池配置管理", tags = "废案池配置管理")
public class AbolishPoolController {

    @Autowired
    private AbolishPoolService abolishPoolService;

    @PostMapping("/save")
    @ApiOperation(value = "新增/修改废案菜单接口", notes = "新增/修改废案菜单")
    public Result save(@RequestBody SaveAbolishPoolRequest request) {
        return abolishPoolService.save(request);
    }

    @Permission(code = "abolishCase")
    @PostMapping("/page")
    @ApiOperation(value = "分页查询废案池配置接口", notes = "分页查询废案池配置接口")
    public Result<PageVO<AbolishPoolResponse>> page(@RequestBody QueryAbolishPoolRequest request) {
        return abolishPoolService.query(request);
    }

    @Permission(code = "abolishCase:del")
    @GetMapping("/delete")
    @ApiOperation(value = "配置删除接口", notes = "配置删除")
    public Result delete(String configId) {
        if (StringUtil.isBlank(configId)) {
            return Result.faild("配置id为空，请检查！！");
        }
        return abolishPoolService.delete(configId);
    }

}
